package com.bohua.Car.admin.controller;

import com.bohua.Car.admin.common.Lay;
import com.bohua.Car.admin.common.Msg;
import com.bohua.Car.admin.entity.Customers;
import com.bohua.Car.admin.service.CarService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/Car")
public class CarController {

    @Resource
    private CarService carService;

    /**
     * 返回视图
     * @return
     */
    @RequestMapping
    public String car(){ return "type/CarType.html"; }
    @RequestMapping("/addCar")
    public String addCar(){ return "type/addType.html"; }
    @RequestMapping("/updeteCar")
    public String updateCar(){ return "type/updateType.html"; }

    /**
     * 删除
     * @param customers
     * @return
     */
    @RequestMapping("/del")
    @ResponseBody
    public Msg delCar(Customers customers){
        return carService.delCar(customers);
    }

    /**
     * 添加
     * @param customers
     * @return
     */
    @RequestMapping("/addType")
    @ResponseBody
    public Msg add(Customers customers){
        return carService.addCar(customers);
    }
    /**
     * 修改
     * @param customers
     * @return
     */
    @RequestMapping("/updateCar")
    @ResponseBody
    public Msg updete(Customers customers){
        return carService.updateCar(customers);
    }
    /**
     * 查询
     * @param customers
     * @param page
     * @param limit
     * @return
     */
    @RequestMapping("/getCars")
    @ResponseBody
    public Lay getTypes(Customers customers, Integer page, Integer limit){
        return carService.getType(customers,page,limit);
    }
}
